home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 2: Applications / Linux Cubed Series 2 - Applications.iso / editors / emacs / xemacs / xemacs-1.006 / xemacs-1 / lib / xemacs-19.13 / lisp / ilisp / ilisp-cmt.el < prev    next >
Encoding:
Text File  |  1995-01-26  |  2.6 KB  |  88 lines

  1. ;;; -*- Mode: Emacs-Lisp -*-
  2.  
  3. ;;; ilisp-cmt.el --
  4.  
  5. ;;; This file is part of ILISP.
  6. ;;; Version: 5.7
  7. ;;;
  8. ;;; Copyright (C) 1990, 1991, 1992, 1993 Chris McConnell
  9. ;;;               1993, 1994 Ivan Vasquez
  10. ;;;               1994, 1995 Marco Antoniotti and Rick Busdiecker
  11. ;;;
  12. ;;; Other authors' names for which this Copyright notice also holds
  13. ;;; may appear later in this file.
  14. ;;;
  15. ;;; Send mail to 'ilisp-request@lehman.com' to be included in the
  16. ;;; ILISP mailing list. 'ilisp@lehman.com' is the general ILISP
  17. ;;; mailing list were bugs and improvements are discussed.
  18. ;;;
  19. ;;; ILISP is freely redistributable under the terms found in the file
  20. ;;; COPYING.
  21.  
  22.  
  23. ;;;
  24. ;;; ILISP comint interface code.
  25. ;;;
  26. ;;;
  27.  
  28.  
  29. ;;;%Process interface
  30. ;;;%%Comint 
  31. (defun ilisp-get-old-input ()
  32.   "Snarf the sexp starting at the nearest previous prompt, or NIL if none."
  33.   (save-excursion
  34.     (let* ((begin (lisp-defun-begin))
  35.        (pmark (process-mark (get-buffer-process (current-buffer))))
  36.        (once (if (< (point) pmark)
  37.              (save-excursion (end-of-line) (point))))
  38.        (end nil)
  39.        (done nil))
  40.       (condition-case ()
  41.       (while (and (not done) (< (point) (point-max)))
  42.         (forward-sexp)
  43.         (setq end (point))
  44.         (skip-chars-forward " \t\n")
  45.         (if (and once (>= (point) once)) (setq done t)))
  46.     (error (setq end nil)))
  47.       (if end (buffer-substring begin end)))))
  48.  
  49. ;;;
  50. (defun ilisp-input-filter (str)
  51.   "Don't save anything matching ilisp-filter-regexp or less than
  52. ilisp-filter-length long."
  53.   (and (not (string-match ilisp-filter-regexp str))
  54.        (> (length str) ilisp-filter-length)))
  55.  
  56. ;;;
  57. (defun ilisp-error-filter (output)
  58.   "Keep from OUTPUT only what matches ilisp-error-regexp or everything
  59. if there is no match."
  60.   (if (string-match (ilisp-value 'ilisp-error-regexp) output)
  61.       (substring output (match-beginning 0) (match-end 0))
  62.       output))
  63.  
  64.  
  65.  
  66. (defun newline-and-indent-lisp ()
  67.   "If at the end of the buffer, send the string back to the process
  68. mark with no newline.  Otherwise, insert a newline, then indent.  In
  69. an ilisp buffer the region is narrowed first.  See newline-and-indent
  70. for more information."
  71.   (interactive "*")
  72.   (if ilisp-complete
  73.       (exit-minibuffer)
  74.       (let (input)
  75.     (if (and (= (point) (point-max)) 
  76.          (memq major-mode ilisp-modes)
  77.          (setq input (ilisp-get-old-input)))
  78.         (let ((process (ilisp-process))
  79.           (comint-send-newline (not comint-send-newline)))
  80.           (funcall comint-input-sender process input)
  81.           (set-marker (process-mark process) (point)))
  82.         (save-restriction
  83.           (if (memq major-mode ilisp-modes)
  84.           (narrow-to-region (save-excursion (lisp-input-start))
  85.                     (point-max)))
  86.           (newline-and-indent))))))
  87.  
  88.